Skip to contentSkip to conversation

Modifying OpenVPN Source Code to Allow for Bulk-Reads, Max-MTU, and Jumbo-TCP

Openvpn-devel Jon Chiappetta 3 participants 6 messages Aug 6, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]...

#1 lore raw

Hi,

This is my first time posting to a mailing list. I worked on a possible performance proof-of-concept modification to the OpenVPN source code. The code is in rough shape as I just wrote it this long weekend but I wanted to see if anyone had any interesting feedback for such work.

Blog Post:
https://fossjon.com/2025/08/05/modifying-openvpn-source-code-to-allow-for-bulk-reads-max-mtu-and-jumbo-tcp-for-highly-improved-performance/

POC Diff: https://github.com/stoops/openvpn/compare/main…mods

If this is the wrong place I apologize in advance, Thanks for your time,

Jon Chiappetta

#2 lore raw

Am 06.08.25 um 05:46 schrieb Jon Chiappetta via Openvpn-devel:

Quoted 9 lines

Hi,

This is my first time posting to a mailing list. I worked on a possible performance proof-of-concept modification to the OpenVPN source code. The code is in rough shape as I just wrote it this long weekend but I wanted to see if anyone had any interesting feedback for such work.

Blog Post: https://fossjon.com/2025/08/05/modifying-openvpn-source-code- to-allow-for-bulk-reads-max-mtu-and-jumbo-tcp-for-highly-improved- performance/ <https://fossjon.com/2025/08/05/modifying-openvpn-source- code-to-allow-for-bulk-reads-max-mtu-and-jumbo-tcp-for-highly-improved- performance/>

Max MTU which now matches the rest of your network clients (1500 bytes)

I have no idea what this means. OpenVPN always supported different MTU sizes and MTU 1500 is standard.

Quoted 3 lines

Bulk reads from the tun interface (6 reads)
TCP connection protocol only (single jumbo write transfers) Performance improvements now allows for (6 reads x 1500 bytes == 9000 bytes)

So basically, from your explanation the main thing is to try to write/read multiple packets in one batch on the TCP socket instead of just reading/writing a single packet. I can see that this improves performance.

Do you have any idea how much this actually improves performance? Your blog post shows a speedtest with 500 MBit/s but that is not actually saying much. In my own test setup, the current OpenVPN is capable over a Gigabit, a before/after from your test setup would nice to see.

Quoted 1 line

POC Diff: https://github.com/stoops/openvpn/compare/main <https:// github.com/stoops/openvpn/compare/main>…mods

Might be good enough for a POC but from quick glance it looks like there needs to cleanup make this an actual commit.

Quoted 3 lines

If this is the wrong place I apologize in advance, Thanks for your time,

No, this is the right place.

Arne

#3 lore raw

Thank you for your reply Arne.

I didn't want to interrupt the regular OpenVPN development workflow process here with some theoretical development questions. I still need to clean up the code so that it would set and respect a user's option to turn this feature on (1 client-side setting, multi server-side settings) and to also not automatically override important variables/values/methods/functions within the rest of the code base either (first time going through the code). I also need to see if any better code optimizations could be made as I'm not an expert on this code base like the others here may be.

Is there any development setup guide I could follow in the future which would allow me to submit a pull request to the OpenVPN codebase in an official manner?

Thanks again for your work and time,
Jon Chiappetta

Quoted 50 lines · Arne Schwabe

Am 06.08.25 um 05:46 schrieb Jon Chiappetta via Openvpn-devel:

Quoted 15 lines

Hi,

This is my first time posting to a mailing list. I worked on a possible performance proof-of-concept modification to the OpenVPN source code. The code is in rough shape as I just wrote it this long weekend but I wanted to see if anyone had any interesting feedback for such work.

Blog Post: https://fossjon.com/2025/08/05/modifying-openvpn-source-code-
to-allow-for-bulk-reads-max-mtu-and-jumbo-tcp-for-highly-improved- performance/ <https://fossjon.com/2025/08/05/modifying-openvpn-source-
code-to-allow-for-bulk-reads-max-mtu-and-jumbo-tcp-for-highly-improved- performance/>

Quoted 1 line

Max MTU which now matches the rest of your network clients (1500 bytes)

I have no idea what this means. OpenVPN always supported different MTU sizes and MTU 1500 is standard.

Quoted 3 lines

Bulk reads from the tun interface (6 reads)
TCP connection protocol only (single jumbo write transfers) Performance improvements now allows for (6 reads x 1500 bytes == 9000

bytes)

So basically, from your explanation the main thing is to try to write/read multiple packets in one batch on the TCP socket instead of just reading/writing a single packet. I can see that this improves performance.

Do you have any idea how much this actually improves performance? Your blog post shows a speedtest with 500 MBit/s but that is not actually saying much. In my own test setup, the current OpenVPN is capable over a Gigabit, a before/after from your test setup would nice to see.

Quoted 2 lines

POC Diff: https://github.com/stoops/openvpn/compare/main <https://
github.com/stoops/openvpn/compare/main>…mods

Might be good enough for a POC but from quick glance it looks like there needs to cleanup make this an actual commit.

Quoted 3 lines

If this is the wrong place I apologize in advance, Thanks for your time,

No, this is the right place.

Arne

#4 lore raw

Hi,

Quoted 3 lines · Jon Chiappetta via Openvpn-devel

Is there any development setup guide I could follow in the future which would allow me to submit a pull request to the OpenVPN codebase in an official manner?

https://community.openvpn.net/Development/DeveloperDocumentation

which is outdated in a few places, but the most important thing is still correct: we don't do Github PRs, we do "patch on list" or "push to gerrit".

Before you spend too much time on actual code, it makes sense to see if there is general agreement on the problem statement, and the direction to fix it. For problems that we cannot understand, it's slightly harder to convince us to accept the code (and the maintenance and testing obligation that comes with each new line of code).

So far I have heard "MTU mumble mumble" and we do have lots of MTUs of all sorts already :-)

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#5 lore raw

Hi Gert,

Thank you for the documentation link, I will try to take a look at it when I get some free time from work and life. I think my specific use case is a bit different than other peoples. I think most people run VPN clients directly on their client host machines which means that their host operating system and network stack will honor a lower sized MTU directly before sending network data outbound.

In my use case, I am piping my entire home WiFi network traffic through a dedicated Linux VM running on a Mac Mini which can result in some serious issues if I'm not careful enough. The reason why MTU size (1500 bytes) is important to me is because all of my network clients will auto assume the standard 1500 bytes once they join a network. This means that if my middle network VPN link MTU is <1500, it will likely cause fragmentation issues for my LAN clients which I really don't want performance wise. If the VPN link MTU is >1500, then my ISP will fragment my packets at the router WAN side as that is the network standard there also. In addition, the code base is only performing singular read/write MTU-sized calls and sending them out right away which also greatly impacts potential performance as well.

With my modifications made, I can specifically and directly target an exact 1500 byte MTU VPN link so that it correctly matches the LAN and WAN side of the networks which is really important network wise and I can also let TCP at the kernel level beautifully handle huge streams of bulk data and ordering and delivery on my behalf as efficiently as possible. This would be a pretty nice modification if I could make it through to the end.

This is one of the reasons why I dislike WireGuard personally. It's at the kernel level instead of application level, it enforces a very small sized MTUs potentially causing fragmentation and performance issues and its UDP based only. :/

Thanks for your time on this,
Jon Chiappetta

Quoted 35 lines · Gert Doering

Hi,

Quoted 3 lines · Jon Chiappetta via Openvpn-devel

Is there any development setup guide I could follow in the future which would allow me to submit a pull request to the OpenVPN codebase in an official manner?

https://community.openvpn.net/Development/DeveloperDocumentation

which is outdated in a few places, but the most important thing is still correct: we don't do Github PRs, we do "patch on list" or "push to gerrit".

Before you spend too much time on actual code, it makes sense to see if there is general agreement on the problem statement, and the direction to fix it. For problems that we cannot understand, it's slightly harder to convince us to accept the code (and the maintenance and testing obligation that comes with each new line of code).

So far I have heard "MTU mumble mumble" and we do have lots of MTUs of all sorts already :-)

gert
--
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never
doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh
Mistress

Gert Doering - Munich, Germany
[email protected]...

#6 lore raw

Hi,

Quoted 6 lines · Jon Chiappetta via Openvpn-devel

With my modifications made, I can specifically and directly target an exact 1500 byte MTU VPN link so that it correctly matches the LAN and WAN side of the networks which is really important network wise and I can also let TCP at the kernel level beautifully handle huge streams of bulk data and ordering and delivery on my behalf as efficiently as possible. This would be a pretty nice modification if I could make it through to the end.

This is *exactly* what OpenVPN will do out of the box, as of today - do an interface MTU of 1500 (unless told otherwise), and if you do TCP, the TCP layer will handle the necessary segmentation. If you do UDP, you get outside fragmentation.

Here's a few tcpdumps in different config scenarios, demonstrating the 1500 bytes "inside" just fine

https://community.openvpn.net/MTU%20and%20Fragments

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...